package name.fowler.refactoring.simplestore.model;

public enum PriceCodes {

    Regular(2, 2, 1.5),
    Childrens(1.5, 3, 1.5),
        NewRelease(3, 1, 3) {
        private int extraPoints = 1;
        
        @Override
        public int getPoints(int days) {
            int basePoints = super.getPoints(days);
            return days > 1 ? basePoints + extraPoints : basePoints;
        }
    };    
    
    private double minPrice;
    private int minDays;
    private double dailyRate;

    private PriceCodes(double minPrice, int minDays, double dailyRate) {
        this.minPrice = minPrice;
        this.minDays = minDays;
        this.dailyRate = dailyRate;
    }

    public double getPrice(int days) {
        double price = minPrice;
        if (days > minDays) {
             price += (days - minDays) * dailyRate;
        }
        return price;
    }
    
    public int getPoints(int days) {
        return 1;
    }
}
